<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of CommentDAO
 *
 * @author Hoang Thanh Duc
 */
class CommentDAO {

    function getComment($product_id){
        $commenttb = new Comment();
        $row = $commenttb->fetchAll($commenttb->select()->where('status = ?',Constant::$STATUS_AVAILABLE)
                            ->where('product_id = ?',$product_id));
        return $row;
    }

    function getCommentList(){
       $commenttb = new Comment();
       $row = $commenttb->fetchAll($commenttb->select()->where('status = ?',Constant::$STATUS_AVAILABLE));
       return $row;
    }

    function searchComment($comment){
        $commenttb = new Comment();
        $row = $commenttb->fetchAll("status =".Constant::$STATUS_AVAILABLE." and comment LIKE '%$comment%'");
        return $row;
    }

    function addComment($data){
        $commenttb = new Comment();
        $commenttb->insert($data);
    }

    function editComment($array){
    	$commenttb = new Comment();
        $where = $commenttb->getAdapter()->quoteInto('id = ?', $array['id']);
        $commenttb->update($array,$where);
    }

    function deleteComment($id){
        $commenttb = new Comment();
        $data = array('status'=>Constant::$STATUS_DELETED);
        $where = $commenttb->getAdapter()->quoteInto('id = ?', $id);
        $commenttb->update($data, $where);
    }
}
?>